<template>
	<view class="content">
		<view class="content_list" v-if="commiconList.length!=0" @click="link('/comm/xiaoxi/xiaoxi?t=msgcomm')">
			<image mode="aspectFit" :src="commicon"></image>
			<view class="right">
				<view class="title">
					<view class="name">社区助手</view>
					<view class="itme">{{commiconList[0].datetime}}</view>
				</view>
				<view class="text">{{commiconList[0].msg}}</view>
			</view>
		</view>
		<view class="content_list" v-if="assistanticonList.length!=0" @click="link('/comm/xiaoxi/xiaoxi?t=msgassistant')">
			<image mode="aspectFit" :src="assistanticon"></image>
			<view class="right">
				<view class="title">
					<view class="name">通讯录助手</view>
					<view class="itme">{{assistanticonList[0].datetime}}</view>
				</view>
				<view class="text">{{assistanticonList[0].msg}}</view>
			</view>
		</view>
		<view class="content_list" v-if="systemiconList.length!=0" @click="link('/comm/xiaoxi/xiaoxi?t=msgsystem')">
			<image mode="aspectFit" :src="systemicon"></image>
			<view class="right">
				<view class="title">
					<view class="name">系统消息</view>
					<view class="itme">{{systemiconList[0].datetime}}</view>
				</view>
				<view class="text">{{systemiconList[0].msg}}</view>
			</view>
		</view>
		<view class="content_list" v-if="acceptfriendiconList.length!=0" @click="link('/comm/xiaoxi/xiaoxi?t=msgnewfriend')">
			<image mode="aspectFit" :src="acceptfriendicon"></image>
			<view class="right">
				<view class="title">
					<view class="name">好友消息</view>
					<view class="itme">{{acceptfriendiconList[0].datetime}}</view>
				</view>
				<view class="text">{{acceptfriendiconList[0].msg}}</view>
			</view>
		</view>
		<view class="content_list" v-if="friends.length!=0" v-for="(v,k) in friends" :key="k" @click="link('/comm/new/new?id='+v.fuid)">
			<image mode="aspectFit" :src="v.headerimg"></image>
			<view class="right">
				<view class="title">
					<view class="name">{{v.lxr}}</view>
					<view class="itme">{{v.datetime}}</view>
				</view>
				<view class="text">{{v.company}}</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import card from '@/components/card/card.vue'
	import {link} from '@/utils/utils.js'
	import {
		ref
	} from 'vue'
	import {
		homeApi
	} from "@/api/index"
	import {
		onLoad,
		onShow
	} from '@dcloudio/uni-app'
	onShow(()=>{
		getData()
	})
	const commicon = ref('')
	const commiconList = ref([])
	const assistanticon = ref('')
	const assistanticonList = ref([])
	const systemicon = ref('')
	const systemiconList = ref([])
	const acceptfriendicon = ref('')
	const acceptfriendiconList = ref([])
	const friends = ref([])
	const getData = async()=>{
		let data = {
			do:'txlmessage'
		}
		let res = await homeApi.publicGet(data)
		for (let i = 0; i < res.columns.length; i++) {
			if (res.columns[i].name == 'txlmessage') {
				commicon.value = res.columns[i].commicon?res.columns[i].commicon:''
				commiconList.value = res.columns[i].comm?res.columns[i].comm:[]
				assistanticon.value = res.columns[i].assistanticon?res.columns[i].assistanticon:''
				assistanticonList.value = res.columns[i].assistant?res.columns[i].assistant:[]
				systemicon.value = res.columns[i].systemicon?res.columns[i].systemicon:''
				systemiconList.value = res.columns[i].system?res.columns[i].system:[]
				acceptfriendicon.value = res.columns[i].acceptfriendicon?res.columns[i].acceptfriendicon:''
				acceptfriendiconList.value = res.columns[i].acceptfriend?res.columns[i].acceptfriend:[]
				friends.value = res.columns[i].friends?res.columns[i].friends:[]
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		width: 100%;
		&_list{
			width: calc(100% - 60rpx);
			padding: 30rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border: 1px solid #f5f6fa;
			image{
				width: 130rpx;
				height: 130rpx;
				border-radius: 100%;
			}
			.right{
				width: calc(100% - 150rpx);
				height: 110rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				.title{
					display: flex;
					justify-content: space-between;
					width: 100%;
					.name{
						font-size: 32rpx;
						font-weight: bold;
					}
					.itme{
						font-size: 28rpx;
						color: #888;
					}
				}
				.text{
					font-size: 28rpx;
					color: #888;
				}
			}
		}
	}
</style>